#{extends 'head.html' /}
#{ set title:'蓝莲花 | 忘记密码'/}

 <style type="text/css">
		.code{
		background-image:url(code.jpg);
		font-family:Arial;
		font-style:italic;
		color:Red;
		border:0;
		padding:2px 3px;
		letter-spacing:3px;
		font-weight:bolder;
		}
		.unchanged {
		border:0;
		}
	</style>
	
	<link rel="stylesheet" href="/public/stylesheets/alert.css" type="text/css" />
	<script type="text/javascript" src="/public/javascripts/adu.alert.js"></script>
    <body onload="createCode();clear();" >

<!-- content 开始-->
    <div class="cont">
    	<div class="cn_a_r1 mem_a">
            <div class="cr1_n"><select><option>书籍名字</option></select></div>
            <div class="cr1_x"><input type="text"/></div>
            <div class="cr1_v"><a href="#"><img src="@{'/public/indexFile/images/images_19.gif'}"/></a></div>
            <div class="cr1_m">
                <ul>
                    <li class="mvn">热门搜索：</li>
                    <li><a href="#">微微书香</a></li>
                    <li><a href="#">微微书香</a></li>
                    <li><a href="#">微微书香</a></li>
                    <li><a href="#">微微书香</a></li>
                </ul>
            </div>
        </div>
    	<div class="mem2_b">
        	<div class="m2_b_a">
            	<ul>
                    <li class="m2_v">您的位置：</li>
                    <li class="m2_c"><a href="#">首页</a></li>
                    <li><a href="#">忘记密码？</a></li>
                    <li><a href="#">通过邮箱确认</a></li>
                </ul>
            </div>
            <div class="m2_b_b">
            	<ul>
                	<li>1、忘记密码？</li>
                    <li>2、通过邮箱确认</li>
                    <li class="m2_ba">3、找回密码</li>
                </ul>
            </div>
            <div style="display: inline;float: left;height: 350px;margin-left: 180px;overflow: hidden;width: 795px;" >
           		<div style="margin:60px auto;width:500px;">
	           		<div class="m2_b_c1">
	                	<div class="m2c_a">新密码：</div>
	                    <div class="m2c_b"><input onblur="ckep(this,'password');" id="password" type="password"/></div>
	                    <div class="m2c_c"><label id="span_pone">请输入您的密码！</label><label style="display:none;" id="span_ptwo">6-16位字符，可由中文、英文、数字及'_'组成</label><label style="display:none;color:red;" id="span_pthree">密码不能为空！</label></div>
	                </div>
	                <div class="m2_b_c1">
	                	<div class="m2c_a">确认密码：</div>
	                    <div class="m2c_b"><input onblur="ckep(this,'repassword');" id="repassword" type="password"/></div>
	                    <div class="m2c_c"><label id="span_rpone">请再输入您的密码！</label><label style="display:none;" id="span_rptwo">6-16位字符，可由中文、英文、数字及'_'组成</label><label style="display:none;color:red;" id="span_rpthree">两次密码不一样，请您重新输入！</label></div>
	                </div>
	                <div class="m2_b_c1">
                	<div class="m2c_a">验证码：</div>
                    <div class="m2c_b m2cm"><input id="input1" type="text"/></div>
                     <div class="m2c_c"><label id="ckeckcode" style="margin-left:10px;color:red;display:none;">验证码错误！</label></div>
                </div>
                <div class="m2_b_c2">
                	<div class="m2c2_a"><input type="text" readonly="true"  id="checkCode" class="code" style="width: 120px;height:45px;text-align:center;font-size:22px;" /></div>
                    <div class="m2c2_b"><a onclick="createCode();" href="javascript:void(0);">看不清楚换一张？</a></div>
                </div>
                <div class="m2_b_c4"><a id="subtt" href="javascript:void(0);"><img src="@{'/public/indexFile/images/mem2_04.gif'}"/></a></div>
           		</div>
            </div>
             <script type="text/javascript">
        	function ckep(obj,type){
        		var objact = obj.value;
        		if(objact != null && "" != objact ){
					switch(type){
						case 'password' :
							if(!(/^[a-zA-Z0-9_]{6,16}$/.test(objact))){
								$("#span_pone").css("display","none");
								$("#span_ptwo").css("display","block");
								$("#span_ptwo").css("color","red");
								return false;
							}else{
								$("#span_pone").css("display","none");
								$("#span_ptwo").css("display","none");
								$("#span_pthree").css("display","none");
							}
						break;
						case 'repassword' :
							var password = $("#password").val();
							var repassword = $("#repassword").val();
							if(!(/^[a-zA-Z0-9_]{6,16}$/.test(objact))){
								$("#span_rpone").css("display","none");
								$("#span_rptwo").css("display","block");
								$("#span_rptwo").css("color","red");
								return false;
							}
							if(password != repassword ){
								$("#span_rpone").css("display","none");
								$("#span_rptwo").css("display","none");
								$("#span_rpthree").css("display","block");
								return false;
							}else{
								$("#span_rpone").css("display","none");
								$("#span_rptwo").css("display","none");
								$("#span_rpthree").css("display","none");
							}
						break;
					}
				}
        	}
        	
        		var code ; //在全局 定义验证码
				function createCode(){
					code = "";
					var codeLength = 4;//验证码的长度
					var checkCode = document.getElementById("checkCode");
					checkCode.value = "";
					
					var selectChar = new Array(2,3,4,5,6,7,8,9,'A','B','C','D','E','F','G','H','J','K','L','M','N','P','Q','R','S','T','U','V','W','X','Y','Z');
					
					for(var i=0;i<codeLength;i++) {
					   var charIndex = Math.floor(Math.random()*32);
					   code +=selectChar[charIndex];
					}
					if(code.length != codeLength){
					   createCode();
					}
					checkCode.value = code;
				}
				
		   		$("#subtt").click(function(){
		   			var regemail = $("#regemail").val();
		   			var password = $("#password").val(); 
		   			var repassword = $("#repassword").val(); 
		   			var password = $("#password").val();
					var repassword = $("#repassword").val();
		   			
		   			if(regemail == ""){
		   				$("#span_one").css("display","none");
		   				$("#span_two").css("display","none");
		   				$("#span_three").css("display","block");
		   				$("#regemail").css("border","red");
		   				return false;
		   			}
		   			$("#span_three").css("display","none");
		   			if(password == ""){
		   				$("#span_pone").css("display","none");
		   				$("#span_ptwo").css("display","none");
		   				$("#span_pthree").css("display","block");
		   				$("#password").css("border","red");
		   				return false;
		   			}
		   			$("#span_pthree").css("display","none");
		   			if(repassword == ""){
		   				$("#span_rptwo").css("display","none");
		   				$("#span_rpone").css("display","block");
		   				$("#repassword").css("border","red");
		   				return false;
		   			}
		   			$("#span_rpone").css("display","none");
		   			
		   			if(password == repassword ){
						$("#span_rpone").css("display","none");
						$("#span_rptwo").css("display","none");
						$("#span_rpthree").css("display","none");
					}
		   			
		   			var inputCode = document.getElementById("input1").value.toUpperCase();
					
					if(inputCode.length <=0) {
					   $("#ckeckcode").css("display","block");
					   return false;
					}
					else if(inputCode != code ){
					   $("#ckeckcode").css("display","block");
					   createCode();
					   return false;
					}else{
						$.ajax({
			   				type:'post',
			   				url :'/controllers/MemberRegAction.mregsave',
			   				dataType:'html',
			   				data:({'uemail':$("#regemail").val(),'upwd':$("#password").val(),'memnum':$("#memnum").val()}),
			   				success:function(e){
			   					if(e == "1"){
			   						aduAlert("注册成功！","提示",function(){
			   							window.location.href="/index.html";
			   						});
			   					}
			   					if(e == "0"){
			   						aduAlert("注册失败！","提示",function(){
			   							createCode();
			   							return false;
			   						});
			   					}
			   				}
			   			});
			   			return true;
					}
		   		});
        </script>
      </div>
